/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * jFPessoaFisica.java
 *
 * Created on 03/08/2012, 01:50:16
 */

package ecommercial;

import ecommercial.Classes.ClassConecta;
import ecommercial.Classes.Funcoes;
import ecommercial.Classes.PessoasFisicas;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.ParseException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author vitiazze
 */
public class jFPessoaFisica extends javax.swing.JDialog {

    /** Creates new form jFPessoaFisica */
    public jFPessoaFisica() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jToolBar1 = new javax.swing.JToolBar();
        buscarjButton = new javax.swing.JButton();
        novojButton = new javax.swing.JButton();
        editarjButton = new javax.swing.JButton();
        salvarjButton = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JToolBar.Separator();
        alterarjButton = new javax.swing.JButton();
        excluirjButton = new javax.swing.JButton();
        jSeparator2 = new javax.swing.JToolBar.Separator();
        sairjButton = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        gradePessoaFisicajTable = new javax.swing.JTable();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel3 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        cpfjFormattedTextField = new javax.swing.JFormattedTextField();
        verificaCPFjCheckBox = new javax.swing.JCheckBox();
        rgjTextField = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        sexojComboBox = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        estadoCiviljComboBox = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        nomePaijTextField = new javax.swing.JTextField();
        nomeMaejTextField = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        localTrabalhojTextField = new javax.swing.JTextField();
        tituloEleitorjTextField = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        carteiraHabilitacaojTextField = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        nacionalidadejTextField = new javax.swing.JTextField();
        apelidojTextField = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        inscEmpreendedorIndividualjTextField = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        valorRendaInformaljFormattedTextField = new javax.swing.JFormattedTextField();
        valorrendaFormaljFormattedTextField = new javax.swing.JFormattedTextField();
        jLabel14 = new javax.swing.JLabel();
        valorRendaFamiliarjFormattedTextField = new javax.swing.JFormattedTextField();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        qtdintegrantesFamiliajTextField = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setName("Form"); // NOI18N
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(ecommercial.EcommercialApp.class).getContext().getResourceMap(jFPessoaFisica.class);
        jToolBar1.setBackground(resourceMap.getColor("jToolBar1.background")); // NOI18N
        jToolBar1.setFloatable(false);
        jToolBar1.setRollover(true);
        jToolBar1.setName("jToolBar1"); // NOI18N

        buscarjButton.setBackground(resourceMap.getColor("buscarjButton.background")); // NOI18N
        buscarjButton.setIcon(resourceMap.getIcon("buscarjButton.icon")); // NOI18N
        buscarjButton.setText(resourceMap.getString("buscarjButton.text")); // NOI18N
        buscarjButton.setFocusable(false);
        buscarjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        buscarjButton.setName("buscarjButton"); // NOI18N
        buscarjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        buscarjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buscarjButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(buscarjButton);

        novojButton.setBackground(resourceMap.getColor("novojButton.background")); // NOI18N
        novojButton.setIcon(resourceMap.getIcon("novojButton.icon")); // NOI18N
        novojButton.setText(resourceMap.getString("novojButton.text")); // NOI18N
        novojButton.setFocusable(false);
        novojButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        novojButton.setName("novojButton"); // NOI18N
        novojButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        novojButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                novojButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(novojButton);

        editarjButton.setBackground(resourceMap.getColor("editarjButton.background")); // NOI18N
        editarjButton.setIcon(resourceMap.getIcon("editarjButton.icon")); // NOI18N
        editarjButton.setText(resourceMap.getString("editarjButton.text")); // NOI18N
        editarjButton.setFocusable(false);
        editarjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        editarjButton.setName("editarjButton"); // NOI18N
        editarjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        editarjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editarjButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(editarjButton);

        salvarjButton.setBackground(resourceMap.getColor("salvarjButton.background")); // NOI18N
        salvarjButton.setIcon(resourceMap.getIcon("salvarjButton.icon")); // NOI18N
        salvarjButton.setText(resourceMap.getString("salvarjButton.text")); // NOI18N
        salvarjButton.setFocusable(false);
        salvarjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        salvarjButton.setName("salvarjButton"); // NOI18N
        salvarjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        salvarjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                salvarjButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(salvarjButton);

        jSeparator1.setName("jSeparator1"); // NOI18N
        jToolBar1.add(jSeparator1);

        alterarjButton.setBackground(resourceMap.getColor("alterarjButton.background")); // NOI18N
        alterarjButton.setIcon(resourceMap.getIcon("alterarjButton.icon")); // NOI18N
        alterarjButton.setText(resourceMap.getString("alterarjButton.text")); // NOI18N
        alterarjButton.setFocusable(false);
        alterarjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        alterarjButton.setName("alterarjButton"); // NOI18N
        alterarjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        alterarjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                alterarjButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(alterarjButton);

        excluirjButton.setBackground(resourceMap.getColor("excluirjButton.background")); // NOI18N
        excluirjButton.setIcon(resourceMap.getIcon("excluirjButton.icon")); // NOI18N
        excluirjButton.setText(resourceMap.getString("excluirjButton.text")); // NOI18N
        excluirjButton.setFocusable(false);
        excluirjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        excluirjButton.setName("excluirjButton"); // NOI18N
        excluirjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        excluirjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                excluirjButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(excluirjButton);

        jSeparator2.setName("jSeparator2"); // NOI18N
        jToolBar1.add(jSeparator2);

        sairjButton.setBackground(resourceMap.getColor("sairjButton.background")); // NOI18N
        sairjButton.setIcon(resourceMap.getIcon("sairjButton.icon")); // NOI18N
        sairjButton.setText(resourceMap.getString("sairjButton.text")); // NOI18N
        sairjButton.setFocusable(false);
        sairjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        sairjButton.setName("sairjButton"); // NOI18N
        sairjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        sairjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sairjButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(sairjButton);

        jPanel1.setBackground(resourceMap.getColor("jPanel1.background")); // NOI18N
        jPanel1.setName("jPanel1"); // NOI18N

        jPanel2.setBackground(resourceMap.getColor("jPanel2.background")); // NOI18N
        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel2.setName("jPanel2"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        gradePessoaFisicajTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "#Id", "Pessoa", "CPF", "Apelido"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        gradePessoaFisicajTable.setName("gradePessoaFisicajTable"); // NOI18N
        gradePessoaFisicajTable.getTableHeader().setReorderingAllowed(false);
        gradePessoaFisicajTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                gradePessoaFisicajTableMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(gradePessoaFisicajTable);
        gradePessoaFisicajTable.getColumnModel().getColumn(0).setResizable(false);
        gradePessoaFisicajTable.getColumnModel().getColumn(0).setPreferredWidth(10);
        gradePessoaFisicajTable.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("gradePessoaFisicajTable.columnModel.title0")); // NOI18N
        gradePessoaFisicajTable.getColumnModel().getColumn(1).setResizable(false);
        gradePessoaFisicajTable.getColumnModel().getColumn(1).setPreferredWidth(200);
        gradePessoaFisicajTable.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("gradePessoaFisicajTable.columnModel.title1")); // NOI18N
        gradePessoaFisicajTable.getColumnModel().getColumn(2).setResizable(false);
        gradePessoaFisicajTable.getColumnModel().getColumn(2).setPreferredWidth(60);
        gradePessoaFisicajTable.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("gradePessoaFisicajTable.columnModel.title2")); // NOI18N
        gradePessoaFisicajTable.getColumnModel().getColumn(3).setResizable(false);
        gradePessoaFisicajTable.getColumnModel().getColumn(3).setPreferredWidth(100);
        gradePessoaFisicajTable.getColumnModel().getColumn(3).setHeaderValue(resourceMap.getString("gradePessoaFisicajTable.columnModel.title3")); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 637, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(18, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTabbedPane1.setName("jTabbedPane1"); // NOI18N

        jPanel3.setBackground(resourceMap.getColor("jPanel3.background")); // NOI18N
        jPanel3.setName("jPanel3"); // NOI18N

        jLabel1.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel1.setForeground(resourceMap.getColor("jLabel1.foreground")); // NOI18N
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        try {
            cpfjFormattedTextField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("###.###.###-##")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        cpfjFormattedTextField.setName("cpfjFormattedTextField"); // NOI18N

        verificaCPFjCheckBox.setText(resourceMap.getString("verificaCPFjCheckBox.text")); // NOI18N
        verificaCPFjCheckBox.setName("verificaCPFjCheckBox"); // NOI18N
        verificaCPFjCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                verificaCPFjCheckBoxActionPerformed(evt);
            }
        });

        rgjTextField.setText(resourceMap.getString("rgjTextField.text")); // NOI18N
        rgjTextField.setName("rgjTextField"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        sexojComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { " ", "Masculino", "Feminino" }));
        sexojComboBox.setName("sexojComboBox"); // NOI18N

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        estadoCiviljComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { " ", "Solteiro (a)", "Casado (a)", "Separado (a)", "Viúvo (a)", "Divorciado (a)", "Desquitado (a)" }));
        estadoCiviljComboBox.setName("estadoCiviljComboBox"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        nomePaijTextField.setText(resourceMap.getString("nomePaijTextField.text")); // NOI18N
        nomePaijTextField.setName("nomePaijTextField"); // NOI18N

        nomeMaejTextField.setText(resourceMap.getString("nomeMaejTextField.text")); // NOI18N
        nomeMaejTextField.setName("nomeMaejTextField"); // NOI18N

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        localTrabalhojTextField.setText(resourceMap.getString("localTrabalhojTextField.text")); // NOI18N
        localTrabalhojTextField.setName("localTrabalhojTextField"); // NOI18N

        tituloEleitorjTextField.setText(resourceMap.getString("tituloEleitorjTextField.text")); // NOI18N
        tituloEleitorjTextField.setName("tituloEleitorjTextField"); // NOI18N

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        carteiraHabilitacaojTextField.setText(resourceMap.getString("carteiraHabilitacaojTextField.text")); // NOI18N
        carteiraHabilitacaojTextField.setName("carteiraHabilitacaojTextField"); // NOI18N

        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N

        nacionalidadejTextField.setText(resourceMap.getString("nacionalidadejTextField.text")); // NOI18N
        nacionalidadejTextField.setName("nacionalidadejTextField"); // NOI18N

        apelidojTextField.setText(resourceMap.getString("apelidojTextField.text")); // NOI18N
        apelidojTextField.setName("apelidojTextField"); // NOI18N

        jLabel11.setText(resourceMap.getString("jLabel11.text")); // NOI18N
        jLabel11.setName("jLabel11"); // NOI18N

        inscEmpreendedorIndividualjTextField.setText(resourceMap.getString("inscEmpreendedorIndividualjTextField.text")); // NOI18N
        inscEmpreendedorIndividualjTextField.setName("inscEmpreendedorIndividualjTextField"); // NOI18N

        jLabel12.setText(resourceMap.getString("jLabel12.text")); // NOI18N
        jLabel12.setName("jLabel12"); // NOI18N

        jLabel13.setText(resourceMap.getString("jLabel13.text")); // NOI18N
        jLabel13.setName("jLabel13"); // NOI18N

        valorRendaInformaljFormattedTextField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#,##0.00"))));
        valorRendaInformaljFormattedTextField.setText(resourceMap.getString("valorRendaInformaljFormattedTextField.text")); // NOI18N
        valorRendaInformaljFormattedTextField.setName("valorRendaInformaljFormattedTextField"); // NOI18N

        valorrendaFormaljFormattedTextField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#,##0.00"))));
        valorrendaFormaljFormattedTextField.setText(resourceMap.getString("valorrendaFormaljFormattedTextField.text")); // NOI18N
        valorrendaFormaljFormattedTextField.setName("valorrendaFormaljFormattedTextField"); // NOI18N

        jLabel14.setText(resourceMap.getString("jLabel14.text")); // NOI18N
        jLabel14.setName("jLabel14"); // NOI18N

        valorRendaFamiliarjFormattedTextField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#,##0.00"))));
        valorRendaFamiliarjFormattedTextField.setText(resourceMap.getString("valorRendaFamiliarjFormattedTextField.text")); // NOI18N
        valorRendaFamiliarjFormattedTextField.setName("valorRendaFamiliarjFormattedTextField"); // NOI18N

        jLabel15.setText(resourceMap.getString("jLabel15.text")); // NOI18N
        jLabel15.setName("jLabel15"); // NOI18N

        jLabel16.setText(resourceMap.getString("jLabel16.text")); // NOI18N
        jLabel16.setToolTipText(resourceMap.getString("jLabel16.toolTipText")); // NOI18N
        jLabel16.setName("jLabel16"); // NOI18N

        qtdintegrantesFamiliajTextField.setText(resourceMap.getString("qtdintegrantesFamiliajTextField.text")); // NOI18N
        qtdintegrantesFamiliajTextField.setName("qtdintegrantesFamiliajTextField"); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(localTrabalhojTextField, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(nomePaijTextField, javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel3Layout.createSequentialGroup()
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel3Layout.createSequentialGroup()
                                    .addComponent(cpfjFormattedTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(verificaCPFjCheckBox))
                                .addComponent(jLabel1))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(rgjTextField)
                                .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                        .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel7, javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel3Layout.createSequentialGroup()
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(nacionalidadejTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE)
                                .addComponent(jLabel10)
                                .addComponent(valorRendaInformaljFormattedTextField))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel11)
                                .addComponent(apelidojTextField)
                                .addComponent(valorrendaFormaljFormattedTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE)
                                .addComponent(jLabel14))))
                    .addComponent(jLabel13))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3)
                            .addComponent(sexojComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(estadoCiviljComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(nomeMaejTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 299, Short.MAX_VALUE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(tituloEleitorjTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 128, Short.MAX_VALUE)
                            .addComponent(jLabel8))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel9)
                            .addComponent(carteiraHabilitacaojTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)))
                    .addComponent(inscEmpreendedorIndividualjTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 299, Short.MAX_VALUE)
                    .addComponent(jLabel12)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(valorRendaFamiliarjFormattedTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel15))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jLabel16)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 6, Short.MAX_VALUE))
                            .addComponent(qtdintegrantesFamiliajTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 135, Short.MAX_VALUE))))
                .addGap(274, 274, 274))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cpfjFormattedTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(verificaCPFjCheckBox)
                    .addComponent(rgjTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(sexojComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(estadoCiviljComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nomePaijTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(nomeMaejTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jLabel8)
                    .addComponent(jLabel9))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(localTrabalhojTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tituloEleitorjTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(carteiraHabilitacaojTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(jLabel11)
                    .addComponent(jLabel12))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nacionalidadejTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(apelidojTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(inscEmpreendedorIndividualjTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(jLabel14)
                    .addComponent(jLabel15)
                    .addComponent(jLabel16))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(valorRendaInformaljFormattedTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(valorrendaFormaljFormattedTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(valorRendaFamiliarjFormattedTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(qtdintegrantesFamiliajTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(14, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab(resourceMap.getString("jPanel3.TabConstraints.tabTitle"), jPanel3); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 297, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 689, Short.MAX_VALUE)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    public ClassConecta conexao = new ClassConecta();

    public int cod_pessoa_pessoaFisica;

    public int pessoaFisica; // essa variavel é usada na grade

    public boolean verifica_CPF;



    public void getGrandePessoaFisica() throws ParseException{
       //Consultar pedidos
        PessoasFisicas oPessoasFisicas = new PessoasFisicas();

        ResultSet resultSet = null;

        String[] colunasTabela = new String[]{"Id#", "Pessoa", "CPF", "Apelido"};
        DefaultTableModel modeloTabela = new DefaultTableModel(null, colunasTabela) {

            @Override
            public boolean isCellEditable(int row, int col) {
                return false;
            }
        };
        gradePessoaFisicajTable.setModel(modeloTabela);
        gradePessoaFisicajTable.getColumnModel().getColumn(0).setPreferredWidth(10);
        gradePessoaFisicajTable.getColumnModel().getColumn(1).setPreferredWidth(200);
        gradePessoaFisicajTable.getColumnModel().getColumn(2).setPreferredWidth(60);
        gradePessoaFisicajTable.getColumnModel().getColumn(3).setPreferredWidth(100);




try {
            oPessoasFisicas.setCod_pessoa(cod_pessoa_pessoaFisica);

            resultSet = oPessoasFisicas.getConsultar();

            if (resultSet.getRow() == 1){
             resultSet.first();
            }


        } catch (SQLException ex) {
            Logger.getLogger(PessoasFisicas.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {

            while (resultSet.next()) {

                modeloTabela.addRow(new String[]{
                    Funcoes.getCodigoFormat(resultSet.getInt("COD_PESSOA")),
                    resultSet.getString("PESSOA"),
                    resultSet.getString("CPF") ,
                    resultSet.getString("APELIDO"),
                });

            }

        } catch (SQLException ex) {
            Logger.getLogger(PessoasFisicas.class.getName()).log(Level.SEVERE, null, ex);
        }

           }
    
    
    public void getFieldTelefone(int codPessoaFisica) throws ParseException{

        PessoasFisicas oPessoaFisica = new PessoasFisicas();
        ResultSet rs = null;
        oPessoaFisica.setCod_pessoa(codPessoaFisica);

        try {
            rs = oPessoaFisica.getConsultar();
            rs.next();

            //Pegar campos
            cpfjFormattedTextField.setText(rs.getString("CPF"));
            rgjTextField.setText(rs.getString("RG"));
            sexojComboBox.setSelectedItem(rs.getString("SEXO"));
            estadoCiviljComboBox.setSelectedItem(rs.getString("ESTADO_CIVIL"));
            nomePaijTextField.setText(rs.getString("NOME_PAI"));
            nomeMaejTextField.setText(rs.getString("NOME_MAE"));
            localTrabalhojTextField.setText(rs.getString("LOCAL_TRABALHO"));
            tituloEleitorjTextField.setText(rs.getString("TITULO_ELEITOR"));
            carteiraHabilitacaojTextField.setText(rs.getString("CARTEIRA_HABILITACAO"));
            nacionalidadejTextField.setText(rs.getString("NACIONALIDADE"));
            apelidojTextField.setText(rs.getString("APELIDO"));
            inscEmpreendedorIndividualjTextField.setText(rs.getString("INSC_EMPREEDEDOR_INDIVIDUAL"));
            valorRendaInformaljFormattedTextField.setText(rs.getString("VALOR_RENDA_INFORMAL"));
            valorrendaFormaljFormattedTextField.setText(rs.getString("VALOR_RENDA_FORMAL"));
            valorRendaFamiliarjFormattedTextField.setText(rs.getString("VALOR_RENDA_FAMILIAR"));
            qtdintegrantesFamiliajTextField.setText(rs.getString("QUANT_INTEGRANTES_FAMILIA"));

        } catch (SQLException ex) {
            Logger.getLogger(PessoasFisicas.class.getName()).log(Level.SEVERE, null, ex);
        }
    }




    private void sairjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sairjButtonActionPerformed
        // TODO add your handling code here:
        if (!novojButton.isEnabled()){

                Object[] options = {"Sim", "Não"};
                int sd = JOptionPane.showOptionDialog(null, "Deseja realmente SAIR?", "Confirmação do Sistema!", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]);
                if (sd != 0) {
                    return;
                }
                this.dispose();
            }
            else{
                this.dispose();
            } 
    }//GEN-LAST:event_sairjButtonActionPerformed

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        // TODO add your handling code here:

        ClassConecta.conecta();
        
        salvarjButton.setEnabled(false);
        alterarjButton.setEnabled(false);
        excluirjButton.setEnabled(false);
        editarjButton.setEnabled(false);
        novojButton.setEnabled(true);
        cpfjFormattedTextField.grabFocus();

        buscarjButtonActionPerformed(null);

    }//GEN-LAST:event_formWindowOpened

    private void novojButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_novojButtonActionPerformed
        // TODO add your handling code here:
        novojButton.setEnabled(false);
        alterarjButton.setEnabled(false);
        editarjButton.setEnabled(false);
        excluirjButton.setEnabled(false);
        buscarjButton.setEnabled(true);
        salvarjButton.setEnabled(true);
        cpfjFormattedTextField.grabFocus();


        cpfjFormattedTextField.setText("");
        carteiraHabilitacaojTextField.setText("");
        sexojComboBox.setSelectedItem(" ");
        estadoCiviljComboBox.setSelectedItem(" ");
        nomePaijTextField.setText("");
        nomeMaejTextField.setText("");
        localTrabalhojTextField.setText("");
        tituloEleitorjTextField.setText("");
        carteiraHabilitacaojTextField.setText("");
        nacionalidadejTextField.setText("");
        apelidojTextField.setText("");
        inscEmpreendedorIndividualjTextField.setText("");
        valorRendaInformaljFormattedTextField.setText("");
        valorrendaFormaljFormattedTextField.setText("");
        valorRendaFamiliarjFormattedTextField.setText("");
        qtdintegrantesFamiliajTextField.setText("");


    }//GEN-LAST:event_novojButtonActionPerformed

    private void salvarjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_salvarjButtonActionPerformed
        // TODO add your handling code here:
            salvarjButton.setEnabled(false);
            alterarjButton.setEnabled(false);
            excluirjButton.setEnabled(false);
            novojButton.setEnabled(true);
            editarjButton.setEnabled(true);

            PessoasFisicas oPessoaFisica = new PessoasFisicas();         

            if(cpfjFormattedTextField.getText().equals("   .   .   -  ")){

                JOptionPane.showMessageDialog(null, "O campo CPF é obrigatório", "ATENÇÃO Mensagem do Sistema", JOptionPane.INFORMATION_MESSAGE);
            
            }else{

                oPessoaFisica.setCod_pessoa(cod_pessoa_pessoaFisica);

                oPessoaFisica.setCpf(cpfjFormattedTextField.getText());
                oPessoaFisica.setRg(rgjTextField.getText().trim().toUpperCase());
                oPessoaFisica.setSexo(sexojComboBox.getSelectedItem().toString());
                oPessoaFisica.setEstado_civil(estadoCiviljComboBox.getSelectedItem().toString());
                oPessoaFisica.setNome_pai(nomePaijTextField.getText().trim().toUpperCase());
                oPessoaFisica.setNome_mae(nomeMaejTextField.getText().trim().toUpperCase());
                oPessoaFisica.setLocal_trabalho(localTrabalhojTextField.getText().trim().toUpperCase());
                oPessoaFisica.setTitulo_eleitor(tituloEleitorjTextField.getText());
                oPessoaFisica.setCarteira_habilitacao(carteiraHabilitacaojTextField.getText());
                oPessoaFisica.setNacionalidade(nacionalidadejTextField.getText().trim().toUpperCase());
                oPessoaFisica.setApelido(apelidojTextField.getText().trim().toUpperCase());
                oPessoaFisica.setInsc_empreededor_individual(inscEmpreendedorIndividualjTextField.getText());
                oPessoaFisica.setValor_renda_informal(Double.parseDouble(valorRendaInformaljFormattedTextField.getValue().toString()));
                oPessoaFisica.setValor_Renda_formal(Double.parseDouble(valorrendaFormaljFormattedTextField.getValue().toString()));
                oPessoaFisica.setValor_Renda_familiar(Double.parseDouble(valorRendaFamiliarjFormattedTextField.getValue().toString()));
                oPessoaFisica.setQuant_integrantes_familia(Integer.parseInt(qtdintegrantesFamiliajTextField.getText()));

                oPessoaFisica.setCadastrar();
            try {
                ClassConecta.con.commit();
                ClassConecta.con.setAutoCommit(true);
            } catch (SQLException ex) {
                Logger.getLogger(jFPessoaFisica.class.getName()).log(Level.SEVERE, null, ex);
            }
            try {
                getGrandePessoaFisica();
            } catch (ParseException ex) {
                Logger.getLogger(jFPessoaFisica.class.getName()).log(Level.SEVERE, null, ex);
            }


            }
    }//GEN-LAST:event_salvarjButtonActionPerformed

    private void buscarjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buscarjButtonActionPerformed
        try {
            // TODO add your handling code here:
            getGrandePessoaFisica();
        } catch (ParseException ex) {
            Logger.getLogger(jFPessoaFisica.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }//GEN-LAST:event_buscarjButtonActionPerformed

    private void verificaCPFjCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_verificaCPFjCheckBoxActionPerformed
        // TODO add your handling code here:
       if(cpfjFormattedTextField.getText().equals("   .   .   -  ")){
           
           JOptionPane.showMessageDialog(null, "O campo CPF é obrigatório", "ATENÇÃO Mensagem do Sistema", JOptionPane.INFORMATION_MESSAGE);
       }else{

           if(verificaCPFjCheckBox.isSelected()){

            Funcoes.verificaCPF(cpfjFormattedTextField.getText()); 
        }      
       }
    }//GEN-LAST:event_verificaCPFjCheckBoxActionPerformed

    private void gradePessoaFisicajTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_gradePessoaFisicajTableMouseClicked
        // TODO add your handling code here:
        editarjButton.setEnabled(true);
            cod_pessoa_pessoaFisica = Integer.parseInt(gradePessoaFisicajTable.getValueAt(gradePessoaFisicajTable.getSelectedRow(), 0).toString());
            if (cod_pessoa_pessoaFisica == 0) {
                return;
            }
        try {
            getFieldTelefone(cod_pessoa_pessoaFisica);
        } catch (ParseException ex) {
            Logger.getLogger(jFTelefones.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_gradePessoaFisicajTableMouseClicked

    private void editarjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editarjButtonActionPerformed
        // TODO add your handling code here:
            novojButton.setEnabled(false);
            salvarjButton.setEnabled(false);
            editarjButton.setEnabled(false);
            alterarjButton.setEnabled(true);
            excluirjButton.setEnabled(true);
        try {
            ClassConecta.con.setAutoCommit(false);
        } catch (SQLException ex) {
            Logger.getLogger(jFPessoas.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_editarjButtonActionPerformed

    private void alterarjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_alterarjButtonActionPerformed
        // TODO add your handling code here:
            alterarjButton.setEnabled(false);
            editarjButton.setEnabled(true);
            excluirjButton.setEnabled(false);
            novojButton.setEnabled(true);

            PessoasFisicas oPessoaFisica = new PessoasFisicas();
            oPessoaFisica.setCod_pessoa(cod_pessoa_pessoaFisica);

                oPessoaFisica.setCpf(cpfjFormattedTextField.getText());
                oPessoaFisica.setRg(rgjTextField.getText().trim().toUpperCase());
                oPessoaFisica.setSexo(sexojComboBox.getSelectedItem().toString());
                oPessoaFisica.setEstado_civil(estadoCiviljComboBox.getSelectedItem().toString());
                oPessoaFisica.setNome_pai(nomePaijTextField.getText().trim().toUpperCase());
                oPessoaFisica.setNome_mae(nomeMaejTextField.getText().trim().toUpperCase());
                oPessoaFisica.setLocal_trabalho(localTrabalhojTextField.getText().trim().toUpperCase());
                oPessoaFisica.setTitulo_eleitor(tituloEleitorjTextField.getText());
                oPessoaFisica.setCarteira_habilitacao(carteiraHabilitacaojTextField.getText());
                oPessoaFisica.setNacionalidade(nacionalidadejTextField.getText().trim().toUpperCase());
                oPessoaFisica.setApelido(apelidojTextField.getText().trim().toUpperCase());
                oPessoaFisica.setInsc_empreededor_individual(inscEmpreendedorIndividualjTextField.getText());
                oPessoaFisica.setValor_renda_informal(Double.parseDouble(valorRendaInformaljFormattedTextField.getValue().toString()));
                oPessoaFisica.setValor_Renda_formal(Double.parseDouble(valorrendaFormaljFormattedTextField.getValue().toString()));
                oPessoaFisica.setValor_Renda_familiar(Double.parseDouble(valorRendaFamiliarjFormattedTextField.getValue().toString()));
                oPessoaFisica.setQuant_integrantes_familia(Integer.parseInt(qtdintegrantesFamiliajTextField.getText()));
                System.out.println(qtdintegrantesFamiliajTextField.getText());

                oPessoaFisica.setAlterar(conexao);
        try {
            ClassConecta.con.commit();
            ClassConecta.con.setAutoCommit(true);
        } catch (SQLException ex) {
            Logger.getLogger(jFPessoaFisica.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            getGrandePessoaFisica();
        } catch (ParseException ex) {
            Logger.getLogger(jFPessoaFisica.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_alterarjButtonActionPerformed

    private void excluirjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_excluirjButtonActionPerformed
        // TODO add your handling code here:
        Object[] options = {"Sim", "Não"};
        int sd =
                JOptionPane.showOptionDialog(null, "Deseja realmente EXCLUIR esse registro?", "Confirmação!", JOptionPane.DEFAULT_OPTION,
                JOptionPane.WARNING_MESSAGE, null, options, options[0]);

        if (sd != 0) {
            return;
        }
        alterarjButton.setEnabled(false);
        editarjButton.setEnabled(true);
        excluirjButton.setEnabled(false);
        novojButton.setEnabled(true);

        int codPessoaFisica = 0;
        codPessoaFisica = Integer.parseInt(gradePessoaFisicajTable.getValueAt(gradePessoaFisicajTable.getSelectedRow(), 0).toString());

        PessoasFisicas oPessoaFisica = new PessoasFisicas();
        oPessoaFisica.setCod_pessoa(codPessoaFisica);
        oPessoaFisica.setExcluir(conexao);
        try {
            ClassConecta.con.commit();
            ClassConecta.con.setAutoCommit(true);
        } catch (SQLException ex) {
            Logger.getLogger(jFPessoas.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            getGrandePessoaFisica();
        } catch (ParseException ex) {
            Logger.getLogger(jFPessoaFisica.class.getName()).log(Level.SEVERE, null, ex);
        }
        cpfjFormattedTextField.setText("");
        carteiraHabilitacaojTextField.setText("");
        sexojComboBox.setSelectedItem(" ");
        estadoCiviljComboBox.setSelectedItem(" ");
        nomePaijTextField.setText("");
        nomeMaejTextField.setText("");
        localTrabalhojTextField.setText("");
        tituloEleitorjTextField.setText("");
        carteiraHabilitacaojTextField.setText("");
        nacionalidadejTextField.setText("");
        apelidojTextField.setText("");
        inscEmpreendedorIndividualjTextField.setText("");
        valorRendaInformaljFormattedTextField.setText("");
        valorrendaFormaljFormattedTextField.setText("");
        valorRendaFamiliarjFormattedTextField.setText("");
        qtdintegrantesFamiliajTextField.setText("");
    }//GEN-LAST:event_excluirjButtonActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new jFPessoaFisica().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton alterarjButton;
    private javax.swing.JTextField apelidojTextField;
    private javax.swing.JButton buscarjButton;
    private javax.swing.JTextField carteiraHabilitacaojTextField;
    private javax.swing.JFormattedTextField cpfjFormattedTextField;
    private javax.swing.JButton editarjButton;
    private javax.swing.JComboBox estadoCiviljComboBox;
    private javax.swing.JButton excluirjButton;
    private javax.swing.JTable gradePessoaFisicajTable;
    private javax.swing.JTextField inscEmpreendedorIndividualjTextField;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JToolBar.Separator jSeparator1;
    private javax.swing.JToolBar.Separator jSeparator2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JTextField localTrabalhojTextField;
    private javax.swing.JTextField nacionalidadejTextField;
    private javax.swing.JTextField nomeMaejTextField;
    private javax.swing.JTextField nomePaijTextField;
    private javax.swing.JButton novojButton;
    private javax.swing.JTextField qtdintegrantesFamiliajTextField;
    private javax.swing.JTextField rgjTextField;
    private javax.swing.JButton sairjButton;
    private javax.swing.JButton salvarjButton;
    private javax.swing.JComboBox sexojComboBox;
    private javax.swing.JTextField tituloEleitorjTextField;
    private javax.swing.JFormattedTextField valorRendaFamiliarjFormattedTextField;
    private javax.swing.JFormattedTextField valorRendaInformaljFormattedTextField;
    private javax.swing.JFormattedTextField valorrendaFormaljFormattedTextField;
    private javax.swing.JCheckBox verificaCPFjCheckBox;
    // End of variables declaration//GEN-END:variables

}
